package com.hhkj.study.admin.dict.service.base.impl;

import cn.hutool.core.collection.CollectionUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.github.pagehelper.PageInfo;
import com.google.common.collect.Maps;
import com.hhkj.study.admin.dict.entity.DictMultiLevel;
import com.hhkj.study.admin.dict.mapper.DictMultiLevelMapper;
import com.hhkj.study.admin.dict.model.podo.DictMultiLevelDo;
import com.hhkj.study.admin.dict.model.podo.DictMultiLevelPo;
import com.hhkj.study.admin.dict.service.base.DictMultiLevelService;
import com.ruoyi.common.base.biz.service.base.BaseServiceImpl;
import com.ruoyi.common.cont.SysConst;
import org.springframework.stereotype.Service;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
*
* @author SERVER
* @since 2024-09-06
*/
@Service
public class DictMultiLevelServiceImpl extends BaseServiceImpl<DictMultiLevel, DictMultiLevelDo, DictMultiLevelPo, DictMultiLevelMapper> implements DictMultiLevelService {

    @Override
    public PageInfo<DictMultiLevelPo> pagingPoByDo(DictMultiLevelDo conditionDo) {
        conditionDo.getPageDomain().setOrderByColumn("orderNum");
        conditionDo.getPageDomain().setIsAsc("asc");
        return super.pagingPoByDo(conditionDo);
    }

    @Override
    public Map<String, String> getOrderColumnMap() {
        return new HashMap<String, String>() {{
            put("orderNum", "xdml.order_num");
            put("id", "xdml.id");
        }};
    }

    @Override
    public List<DictMultiLevel> getDictListEnable(List<String> codeList) {
        LambdaQueryWrapper<DictMultiLevel> dictQueryWrapper = new LambdaQueryWrapper<>();
        dictQueryWrapper.select(DictMultiLevel::getId, DictMultiLevel::getName, DictMultiLevel::getParentId, DictMultiLevel::getLevelCode)
                .in(CollectionUtil.isNotEmpty(codeList), DictMultiLevel::getTypeCode, codeList)
                .eq(DictMultiLevel::getDisableFlag, SysConst.Flag.NO.getFlag());
        return this.list(dictQueryWrapper);
    }
}